package various;


import lejos.nxt.LCD;
import lejos.nxt.Motor;
import lejos.nxt.SensorPort;
import lejos.nxt.TouchSensor;
import lejos.nxt.UltrasonicSensor;

public class Corsa {
	public static void main(String[] args) throws Exception {
		UltrasonicSensor us = new UltrasonicSensor(SensorPort.S3);
		TouchSensor ts = new TouchSensor(SensorPort.S2);
		while (true) {
			if (ts.isPressed()) {
				LCD.clear();
				LCD.drawString("iniziale: " + us.getDistance(), 0, 1);
				Thread.sleep(2000);
			}
			// while(!ts.isPressed()){
			LCD.clear();
			LCD.drawString("corrente: " + us.getDistance(), 0, 2);
			Motor.A.setSpeed(100);
			Motor.A.forward();
			// }
			if (ts.isPressed()) {
				LCD.clear();
				LCD.drawString("finale: " + us.getDistance(), 0, 1);
				Motor.A.stop();
			}
		}
	}

}
